import {del, get, post, put} from "@/api/base/http";
import {ApiUri} from "@/api/base/ApiPath";
// @ts-ignore
import Utils from "@/vue2-flow/src/utils/Common";

let ApiPath = new ApiUri();

export class FlowApi {

    static Gets = () => {
        return get(ApiPath.Flow.LIST);
    }

    static Get = (FlowId: Number) => {
        return get(ApiPath.Flow.ROOT + FlowId);
    }

    static Delete = (Id: number) => {
        return del(ApiPath.Flow.ROOT + Id)
    }

    static Save = () => {
        return post(ApiPath.Flow.ROOT)
    }

    /**
     * 获取所有节点的详细信息
     * @constructor
     */
    static GetAllFlowNodeDetail = () => {
        return get(ApiPath.Flow.ALL_FLOW_NODE_DETAIL)
    }

    static UpdateFlowNode = (FlowId: Number, NodeItemJson: string) => {
        return put(ApiPath.Flow.UPDATE_NODE, {FlowId: FlowId, NodeItemJson: NodeItemJson})
    }

    static UpdateFlow = (Info: object) => {
        return put(ApiPath.Flow.UPDATE_FLOW, Info)
    }
    static GetMesNodeRequestParams = (ApiName: string) => {
        return get(ApiPath.Node.NODE_CONFIG, {ApiName: ApiName})
    }

    static RunFlow = (FlowId: Number) => {
        return post(ApiPath.Flow.RUN + FlowId)
    }

    static StopFlow = (FlowId: Number) => {
        return post(ApiPath.Flow.STOP + FlowId)
    }
}
